package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface UserDao {
/*

    @Select("SELECT * FROM t_user WHERE username=#{username}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "birthday", column = "birthday"),
            @Result(property = "gender", column = "gender"),
            @Result(property = "username", column = "username"),
            @Result(property = "password", column = "password"),
            @Result(property = "remark", column = "remark"),
            @Result(property = "station", column = "station"),
            @Result(property = "telephone", column = "telephone"),
            @Result(property = "roles",column = "id",
                    javaType = Set.class,
                    many = @Many(select = "com.itheima.dao.RoleDao.findRole"))
    })
    User findUser(String username);
*/


    public User findByUsername(String username);

    //抽取的 用户角色关系
    void setUserAndRole(Map<String, Integer> map);

    //添加用户
    void add(User user);

    //分页管理 根据条件查询
    Page<User> selectByCondition(String queryString);

    //回显用户基本信息  未用到
//    User copyback(Integer id);

    //编辑用户
    void edit(User user);

    //回显用户角色信息
    List<Integer> copybackIds(Integer id);

    //删除用户角色关联关系
    void deleteAssociation(Integer id);

    //删除用户
    void del(Integer id);

    //查询用户
    List<User> findalluser();

    public Set<User> findByRoleId(Integer roleId);

    Integer findIdByUsername(String username);
}
